package com.bl.student.dao.model;

import com.bl.student.common.enums.PayBusinessType;
import com.bl.student.common.enums.PayStatus;
import com.bl.student.dao.model.converter.DatetimeConverter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;

/**
 * Created by yujingyi on 2018/3/14.
 */
@Entity
@Data
@Table(name = "PAY")
@ApiModel(value = "PayEntity", description = "支付记录")
@DynamicInsert
@DynamicUpdate
public class PayEntity {
    @Id
    @ApiModelProperty(value = "订单编号")
    @Column(name = "trade_no")
    private String tradeNo;

    @ApiModelProperty(value = "甲方id")
    private String payer;

    @ApiModelProperty(value = "乙方id")
    @Column(name = "user_id")
    private String userId;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "业务类型: ALIPAY 支付宝 WECHAT 微信")
    @Column(name = "business_type")
    private PayBusinessType businessType;

    @ApiModelProperty(value = "支付数额（若是钱时，以分为单位）")
    private String amount;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "订单状态: PAYING 进行中 SUCCESS 成功 FAILED 失败 FINISHED 结束 CLOSED 关闭")
    private PayStatus status;

    @ApiModelProperty(value = "商品id")
    @Column(name = "apply_id")
    private String applyId;

    @ApiModelProperty(value = "创建时间")
    @Column(name = "create_time")
    @Convert(converter = DatetimeConverter.class)
    private Long createTime;

    @ApiModelProperty(value = "更新时间")
    @Column(name = "update_time")
    @Convert(converter = DatetimeConverter.class)
    private Long updateTime;
}
